package com.training.java.core.collections.mutablecar.pre15;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CarDemo {
	public static void main(String[] args) {

		Car car1 = new Car();
		car1.setMake("Honda");
		car1.setModel("Accord");
		car1.setYear(2013);
		car1.setPrice(20000);

		Car car2 = new Car();
		car2.setMake("Toyota");
		car2.setModel("Camry");
		car2.setYear(2013);
		car2.setPrice(30000);

		Car car3 = new Car();
		car3.setMake("Mercedes");
		car3.setModel("Benz");
		car3.setYear(2014);
		car3.setPrice(70000);

		Car car4 = new Car();
		car4.setMake("Mercedes");
		car4.setModel("Benz");
		car4.setYear(2014);
		car4.setPrice(70000);

		System.out.println(car1);
		System.out.println(car2);
		System.out.println(car3);
		System.out.println(car4);

		List carObjects = new ArrayList();

		carObjects.add(car1);
		carObjects.add(car2);
		carObjects.add(car3);
		carObjects.add(car4);

		Iterator ite = carObjects.iterator();

		while (ite.hasNext()) {
			Car car = (Car) ite.next();
			System.out.println("Car Make = " + car.getMake());
			System.out.println("Car Model = " + car.getModel());
			System.out.println("Car Year = " + car.getYear());
			System.out.println("Car Price = " + car.getPrice());

		}

	}

}